package pagelib;
import com.thoughtworks.selenium.*;
public class Page {

	static Selenium BO = new DefaultSelenium("localhost", 4444,"*firefox","http://www.credomobile.com");
	
	
	public void openTest()
	{
		BO.start();
		BO.windowMaximize();
	}
	
	public String getPrice(String elementID)
	{
		String price=null;
		price = getElementText(elementID);
		return (price);
	}
	
	public void clickAddToCart(String idLink)
	{	
		clickVisibleLink(idLink);
	}
	
	
	public void clickVisibleLink(String link)
	{
		if(isElementVisible(link))
			BO.click(link);
		BO.waitForPageToLoad("30000");
	}
	
	public String getElementText(String element)
	{
		String text = null;
		if(isElementVisible(element))
		{
			text = BO.getText(element);
			return(text);
		}
		else
			return (text);
	}
	
	
	public boolean isElementVisible(String element)
	{
		if(BO.isVisible(element))
		{
			return (true);
		}
		else
		{
			System.out.println("Element" + element +"is not visible");
			return(false);
		}
	}
	
	public String getTitle()
	{
		return BO.getTitle();
	}
	
	public void closeTest()
	{
		BO.close();
	}
}
